package com.edocbase.desktop.plugins.mdiary.figures;

import org.eclipse.draw2d.ButtonModel;
import org.eclipse.draw2d.Clickable;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.CompoundBorder;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Toggle;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Rectangle;

import com.edocbase.desktop.lightweight.ui.CompoundBackground;
import com.edocbase.desktop.lightweight.ui.LookAndFeel;
import com.edocbase.desktop.lightweight.ui.RibbonButtonBackground;
import com.edocbase.desktop.lightweight.ui.RibbonButtonBorder;
import com.edocbase.desktop.lightweight.widgets.FigureOwner;
import com.edocbase.desktop.lightweight.widgets.tree.TreeRoot;

public class DiaryFigure extends Clickable {
	private IFigure titleFigure = null;
	private IFigure descFigure = null;
	private IFigure thumbFigure = null;
	private IFigure toolbarFigure = null;

	public static final String LAYOUT_TITLE = DiaryLayout.LAYOUT_TITLE;
	public static final String LAYOUT_DESC = DiaryLayout.LAYOUT_DESC;
	public static final String LAYOUT_THUMB = DiaryLayout.LAYOUT_THUMB;
	public static final String LAYOUT_TOOLBAR = DiaryLayout.LAYOUT_TOOLBAR;
	
	private String diaryId = null;
	private TreeRoot root = null;

	public DiaryFigure() {
		super();
		setLayoutManager(new DiaryLayout());
		setRolloverEnabled(true);
		CompoundBackground cborder = new CompoundBackground(
				new RibbonButtonBorder(), new RibbonButtonBackground());
		// cborder = new CompoundBorder(new RibbonButtonBackground(),new
		// RibbonButtonBorder());
		setBorder(cborder);
	}

	@Override
	public void doClick() {
		super.doClick();
	}

	@Override
	public void add(IFigure figure, Object constraint, int index) {
		super.add(figure, constraint, index);
	}

	@Override
	public Dimension getPreferredSize(int wHint, int hHint) {
		Dimension dimension = super.getPreferredSize(wHint, hHint);
		if (prefSize == null) {
			prefSize = dimension.getCopy();
		}
		if (root.getNodeMaxSize() != null) {
			Dimension d = root.getNodeMaxSize();
			if (d.width > 0) {
				dimension.width = d.width;// Math.min(d.width, dimension.width);
			}
			dimension.height = d.height;// Math.min(d.height, dimension.height);
		}
		return dimension;
	}

	public TreeRoot getRoot() {
		return root;
	}

	public void setRoot(TreeRoot root) {
		this.root = root;
	}

	public String getDiaryId() {
		return diaryId;
	}

	public void setDiaryId(String diaryId) {
		this.diaryId = diaryId;
	}

}
